package com.hyd.util;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class LoginUtil {
	private static boolean isLogin;
	private static SharedPreferences sp;

	public static boolean isLogin(Context context) {
		sp = context.getSharedPreferences("login", Activity.MODE_PRIVATE);
		String account = sp.getString("account", null);
		isLogin = account == null ? false : true;
		return isLogin;
	}
	
	
	public static void Login(String account,String password,Context context){
		sp = context.getSharedPreferences("login", Activity.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putString("account", account);
		editor.putString("password", password);
		editor.commit();
	}
	
	public static void LoginOut(Context context){
		sp = context.getSharedPreferences("login", Activity.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.clear();
		editor.commit();
	}
}
